import { ApiProperty } from "@nestjs/swagger";
import { BaseEntity, PaginatedResult } from "src/common/entities/entities";
import { Status } from "src/dictionaries/index.enum";
import { Column, CreateDateColumn, Entity, FindOperator, JoinColumn, ManyToOne, } from "typeorm";
import { JumpType } from 'src/dictionaries/index.enum';
export enum NoticeType {
    /** 默认 */
    default = 10,
    /** 弹窗公告 */
    POPUP = 20,
}

@Entity('notice')
export class NoticeEntity extends BaseEntity {
    /** 标题 */
    @ApiProperty({ example: 'title', description: '标题' })
    @Column({
        type: 'varchar',
        length: 100,
        comment: '标题',
    })
    title: string;
    /** 内容 */
    @ApiProperty({ example: 'content', description: '内容' })
    @Column({
        type: 'text',
        comment: '内容',
        nullable: true
    })
    content: string;
    /** 有效期开始时间 */
    @ApiProperty({ example: 'expirationStart', description: '有效期开始时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '有效期开始时间',
    })
    expirationStart: string | FindOperator<Date>;
    /** 有效期结束时间 */
    @ApiProperty({ example: 'expirationEnd', description: '有效期结束时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '有效期结束时间',
    })
    expirationEnd: string | FindOperator<Date>;
    /** 跳转链接 */
    @ApiProperty({ example: 'url', description: '跳转链接' })
    @Column({
        type: 'varchar',
        comment: '跳转链接',
        nullable: true
    })
    url: string;
    /** 跳转类型 */
    @ApiProperty({
        enum: JumpType,
        example: JumpType.none,
        description: '跳转类型',
    })
    @Column({
        type: 'enum',
        enum: JumpType,
        default: JumpType.none,
    })
    jumpType: JumpType;

    /** 公告类型 */
    @ApiProperty({
        enum: NoticeType,
        example: NoticeType.default,
        description: '公告类型',
    })
    @Column({
        type: 'enum',
        enum: NoticeType,
        default: NoticeType.default,
    })
    type: NoticeType;
    /** 是否启用 */
    @ApiProperty({
        enum: Status,
        example: Status.ENABLED,
        description: '是否启用',
    })
    @Column({
        type: 'enum',
        enum: Status,
        default: Status.ENABLED,
    })
    status: Status;

}
export class NoticeResult extends PaginatedResult {
    @ApiProperty({ example: 'data', description: 'data' })
    data: NoticeEntity;
}